package com.rao.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: raoguang
 * @Date: 2022/08/22/0:22
 * @Description:
 */
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Value("${file.staticPatternPath}")
    private String staticPatternPath;

    @Value("${file.uploadFolder}")
    private String uploadFolder;

    /**
     * 配置静态资源服务的映射：
     * 这个就是springboot中springMvc让程序开发者去配置文件上传的额外的静态资源服务的配置
     *
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //registry.addResourceHandler("/images/**").addResourceLocations("file:G://image/");
        registry.addResourceHandler(staticPatternPath).addResourceLocations("file:" + uploadFolder);
    }
}


